﻿/*
 * 2023/3/1
 * Autofac的配置类
 * 
 * 
 * **/
using Autofac;

namespace Max.PH5_2008A.ShoppingCode.API.MyConfig
{
    public class AutofacConfig:Autofac.Module
    {
        //这在个方法里面，去注入我们自己的仓储和服务
        protected override void Load(ContainerBuilder builder)
        {
            //System.Reflection.Assembly.Load("相对路径");
            //System.Reflection.Assembly.LoadFile("绝对路径");
            //System.Reflection.Assembly.LoadFrom("两者随便");


            var service = System.Reflection.Assembly.Load("Max.PH5_2008A.ShoppingCode.Service");
            builder.RegisterAssemblyTypes(service)
                .AsImplementedInterfaces()  //是以接口的方式注册
                .InstancePerDependency();// 每次瞬态


            var respository = System.Reflection.Assembly.Load("Max.PH5_2008A.ShoppingCode.Respository");
            builder.RegisterAssemblyTypes(respository)
                .AsImplementedInterfaces()  //是以接口的方式注册
                .InstancePerDependency();// 每次瞬态
        }
    }
}
